package client.comm.baoding.adapter.page

import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import client.comm.octfdsmall.widget.CustomViewPager1
import client.comm.baoding.api.bean.CateGoods
import client.comm.baoding.fragment.CateNewChild2Fragment

class CateGoodsPage2Adapter : FragmentStatePagerAdapter {
    val list: MutableList<CateGoods.TypeInfo>
    val mViewPager1: CustomViewPager1

    constructor(fm: FragmentManager, viewPager1: CustomViewPager1, list: MutableList<CateGoods.TypeInfo>) : super(
        fm,
        BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
    ) {
        this.mViewPager1=viewPager1
        this.list = list
    }


    override fun getItem(position: Int): Fragment {
        return CateNewChild2Fragment(mViewPager1).apply {
            arguments = Bundle().apply {
                putParcelable("bean", list[position])
                putInt("fragmentID", position)
            }
        }
    }

    override fun getCount(): Int {
        return list.size
    }

}